﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MyCadDll.MyObject
{
    public class MyCadObject:Object
    {
        public virtual int CompareTo_X(object obj)
        {
           
            throw new NotImplementedException();

        }

        public virtual int CompareTo_Y(object obj)
        {
            throw new NotImplementedException();
        }

        public int CompareObjTo_X(MyCadObject obj)
        {
            if ((this is MyText && obj is MyText)||
               (this is MyLine && obj is MyLine) )
            {
                return this.CompareTo_X(obj);
            }
            if (this is MyText && obj is MyLine)
            {
                MyText text = this as MyText;
                MyLine line = obj as MyLine;
                return text.Point.CompareTo_X(line.P1);
            }
            if (this is MyLine && obj is MyText)
            {
                MyText text = obj as MyText;
                MyLine line = this as MyLine;
                return line.P1.CompareTo_X(text.Point);
            }
            throw new NotImplementedException();
        }

        public int CompareObjTo_Y(MyCadObject obj)
        {
            if ((this is MyText && obj is MyText) ||
                (this is MyLine && obj is MyLine))
            {
                return this.CompareTo_Y(obj);
            }
            if (this is MyText && obj is MyLine)
            {
                MyText text = this as MyText;
                MyLine line = obj as MyLine;
                return text.Point.CompareTo_Y(line.P1);
            }
            if (this is MyLine && obj is MyText)
            {
                MyText text = obj as MyText;
                MyLine line = this as MyLine;
                return line.P1.CompareTo_Y(text.Point);
            }
            throw new NotImplementedException();
        }
    }
}
